import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

public class exam_02_Server {
    public static void main(String[] args) {
        try {
            ServerSocket serverSocket = new ServerSocket(8888);
            while (true) {
                Socket socket = serverSocket.accept();
                System.out.println("OK!!!");
                File file = new File("D:\\工作\\01_JAVA基础培训\\03_JAVA面向对象\\2 封装性\\1. Java封装性的使用.mp4");
                FileInputStream fi = new FileInputStream(file);
                BufferedInputStream bi = new BufferedInputStream(fi);
                BufferedOutputStream bo = new BufferedOutputStream(socket.getOutputStream());
                byte[] b = new byte[1024];
                int len;
                while ((len = bi.read(b))!=-1) {
                    bo.write(b);
                }
                bo.close();
                bi.close();
                fi.close();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}
